﻿using Mercury.Business.IRepositories;
using Mercury.Business.IServices;
using Mercury.Core.BaseProvider;
using Mercury.Core.Extensions.AutofacManager;
using Mercury.Entity.DomainModels;
using Mercury.Entity.SystemModels;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mercury.Business.Services
{
    public class BaseEntityService : ServiceBase<BaseEntity, IBaseEntityRepository>
    , IBaseEntityService, IDependency
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IBaseEntityRepository _repository;//访问数据库

        public BaseEntityService(IBaseEntityRepository repository)
        : base(repository)
        {
            Init(repository);
        }
        public static IBaseEntityService Instance
        {
            get { return AutofacContainerModule.GetService<IBaseEntityService>(); }
        }

        [ActivatorUtilitiesConstructor]
        public BaseEntityService(
            IBaseEntityRepository dbRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _repository = dbRepository;
        }
    }
}
